<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
    <title>
        js与原生混调
    </title>
</head>

<style type="text/css">
		.parent{
			display: flex;
			flex-direction: column;
		}
		.item{
			margin: 10;
			background-color: #19DDF6;
			padding: 6;
			height:40;
			border:0px solid white;
			color:white;
		}
	</style>

<body>
<div class="parent">
    <input type="button" class="item" value="调用原生无参数无回调方法" onclick="nativeNoArgAndNoCallback()" />
    <input type="button" class="item" value="调用原生无参数有回调方法" onclick="nativeNoArgAndCallback()" />
    <input type="button" class="item" value="调用原生有参数无回调方法" onclick="nativeArgAndNoCallback()" />
    <input type="button" class="item" value="调用原生有参数有回调方法" onclick="nativeArgAndCallback()" />

    <input type="button" class="item" value="调用原生方法后删除回调" onclick="nativeDeleteCallback()" />
    <input type="button" class="item" value="调用原生方法后不删除回调" onclick="nativeNoDeleteCallback()" />

    <input type="button" class="item" value="调用原生方法同步回调" onclick="nativeSyncCallback()" />

    <input type="button" class="item" value="原生弹窗" onclick="nativeDialog()" />
</div>
</body>
<script>

        alert(window.JsBridgeSynchronize.statusHeight())

		function nativeNoArgAndNoCallback(){
			JsBridge.nativeNoArgAndNoCallback();
		}

		function nativeNoArgAndCallback(){
			JsBridge.nativeNoArgAndCallback(function(result){
				alert(JSON.stringify(result));
			});
		}

		function nativeArgAndNoCallback(){
			JsBridge.nativeArgAndNoCallback("调用原生有参数无回调方法");
		}

		function nativeArgAndCallback(){
			JsBridge.nativeArgAndCallback("调用原生有参数有回调方法",function(result){
				alert(JSON.stringify(result))
			});
		}

		function nativeDeleteCallback(){
			JsBridge.nativeDeleteCallback("调用原生方法后删除回调",function(result){
				alert(JSON.stringify(result))
			},function(error){
				alert(JSON.stringify(result))
			});
		}

		function nativeNoDeleteCallback(){
			JsBridge.nativeNoDeleteCallback("调用原生方法后不删除回调",function(result){
				alert(JSON.stringify(result))
			},function(error){
				alert(JSON.stringify(error))
			});
		}

		function nativeDialog(){
			JsBridge.nativeDialog({
				title:"温馨提示",
				content:"天快要下雨了，请大家带好雨伞",
				confirmText:"知道了，谢谢",
				cancelText:"我偏不带"
			},function(result){
				alert(result.data)
			},function(error){
				alert(error.data)
			});
		}

		function nativeSyncCallback(){
			var  result = JsBridge.nativeSyncCallback("");
			alert(result)
		}

		function jsNoArgAndNoCallback(){
			alert("原生调用JS无参数无回调");
		}

		function jsNoArgAndCallback(callback){
			alert("原生调用JS无参数有回调");
			callback("我是JS回调数据");
		}

		function jsArgAndNoCallback(params){
			alert(params);
		}

		function jsArgAndCallback(params,callback){
			alert(params);
			callback("我是JS第一次回调数据");
			setTimeout(function() {
				callback("我是JS第二次回调数据");
			}, 500);
		}

		function jsArgAndDeleteCallback(params,callback){
			alert(params);
			callback("我是JS第一次回调数据",true);
			setTimeout(function() {
				callback("我是JS第二次回调数据");
			}, 500);
		}

	</script>

</html>
